package com.cloud.dao.impl;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Component;

import com.cloud.core.BaseDao;
import com.cloud.dao.CourseBean;

/**
 * 1Cloud1
 * @author Administrator
 * @since 2016-1-16
 * @version 1.0 
 */
@Component("TempleteDao")
public class TempleteDao extends BaseDao {
	
	public List<String> getTableNameByPro(CourseBean course){
		SqlSession session = super.getInstance(true);
		List<String> columnList = null;
		try {
			columnList = session.selectList("course.gettablenamebypro", course);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			session.close();
		}
		return columnList;
	}
	
	public List<String> getTableName(String tempId){
		SqlSession session = super.getInstance(true);
		List<String> columnList = null;
		try {
			columnList = session.selectList("course.gettablename", tempId);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			session.close();
		}
		return columnList;
	}
	
	public List<String> getColumnList(String tempId){
		SqlSession session = super.getInstance(true);
		List<String> columnList = null;
		try {
			columnList = session.selectList("course.columnlist", tempId);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			session.close();
		}
		return columnList;
	}
	
	public List<CourseBean> getCourseList(CourseBean bean){
		SqlSession session = super.getInstance(true);
		List<CourseBean> beanList = null;
		try {
			beanList = session.selectList("course.list", bean);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			session.close();
		}
		return beanList;
	}
	
	public void addCourse(Map<String, String> params){
		SqlSession session = super.getInstance(true);
		session.insert("course.insert", params);
		session.close();
	}
	
	public void deleteCourse(CourseBean bean){
		SqlSession session = super.getInstance(true);
		session.delete("course.delete", bean);
		session.close();
	}
}
